// composables/useEventBus.ts
import mitt from "mitt";

// 为 mitt 方法里的’modify-user‘事件标注类型
interface ModifyUser {
  id: number;
  name: string;
}

// 为 mitt 方法标注类型
type ApplicationEvents = {
  "delete-user": number;
  "modify-user": ModifyUser;
};

const emitter = mitt<ApplicationEvents>();

export const useEmit = emitter.emit; // 触发事件方法 $emits
export const useOn = emitter.on; // 监听事件方法 $on
